<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateScaleDetailsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('scale_details', function (Blueprint $table) {
//            $table->comment('量表考核内容表');
            $table->bigIncrements('id');
            $table->bigInteger('top_id')->nullable()->default(0)->comment('祖指标id，一级指标为0');
            $table->bigInteger('pid')->default(0)->index('pid')->comment('父指标id，一级指标为0');
            $table->bigInteger('scale_id')->default(0)->index('scale_id')->comment('量表id');
            $table->string('title', 255)->default('')->comment('指标标题');
            $table->tinyInteger('score')->nullable()->comment('指标分值');
            $table->string('desc', 255)->nullable()->default('')->comment('详细说明');
            $table->tinyInteger('self_rate')->nullable()->default(0)->comment('是否自评, 1-是,2-否');
            $table->string('review_name', 32)->default('')->comment('评审人');
            $table->string('reviewer', 32)->default('')->comment('评审人关联user_id');
            $table->tinyInteger('level')->default(0)->comment('当前指标层数');
            $table->tinyInteger('tier')->default(0)->comment('总指标层数');
            $table->boolean('is_end')->default(false)->comment('是否是最末层级：0-否，1-是');
            $table->timestamps();
            $table->bigInteger('sort')->default(0)->comment('排序');
            $table->string('thread', 255)->nullable()->default('')->comment('数据链');
            $table->float('min_score', 10, 1)->comment('分值范围 最小分数');
            $table->float('max_score', 10, 1)->comment('分值范围 最大分数');
            $table->string('module', 5)->default('')->comment('对应模块');
            $table->string('scale_index', 5)->default('')->comment('量表索引 ');
            $table->float('single_score', 10, 1)->comment('单项分数');
            $table->float('default_score', 10, 1)->comment('默认分数');
            $table->text('check_module')->comment('学年考核 对应模块');
            $table->text('check_module_text')->comment('学年考核 对应模块名称');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('scale_details');
    }
};
